package com.example.monitor.config;

import javax.sql.DataSource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wangkai
 *从数据源
 */
//@Configuration
//@MapperScan(basePackages = { "com.example.monitor.web.master.mapper" }, sqlSessionFactoryRef = "sqlSessionFactoryCluster")
public class ClusterDataSourceCofinguration {

/*	@Autowired
	@Qualifier("clusterDataSource")
	private DataSource clusterDataSource;

	@Bean
	public SqlSessionFactory sqlSessionFactoryCluster() {
		SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
		factoryBean.setDataSource(clusterDataSource); // 使用titan数据源, 连接titan库
		try {
			return factoryBean.getObject();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Bean
	public SqlSessionTemplate sqlSessionTemplateCluster() {
		SqlSessionTemplate template = new SqlSessionTemplate(
				sqlSessionFactoryCluster()); // 使用上面配置的Factory
		return template;
	}*/

}
